package design_pattern.prototype;

import java.util.List;

/**
 * Created by WeiDingKuo on 2017/10/26 16:30
 * <p>
 * 原型模式
 * 实现CloneAble接口，注意深复制和浅复制的问题
 */
public class Prototype implements Cloneable {
    //深复制
    private int a;
    //浅复制
    private List b;

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }


    public List getB() {
        return b;
    }

    public void setB(List b) {
        this.b = b;
    }

    public Prototype clone() {
        Prototype prototype = null;
        try {
            prototype = (Prototype) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return prototype;
    }
}
